﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Database;
using Business;
using System.Globalization;

namespace DT5_Anh09110006_Hung09110044_Vu09110157.QuanLy
{
    public partial class ThemHocVien : System.Web.UI.Page
    {
        Business.QuanLyHocVien qlhocvien = new Business.QuanLyHocVien();
        protected void Page_Load(object sender, EventArgs e)
        {
           

        }

        protected void btnThemHV_Click(object sender, EventArgs e)
        {
            HocVien hv = new HocVien
            {
                MaHV=txtMaHV.Text,
                HoTenHV=txtHoTenHV.Text,
                DiaChi=txtDiaChiHV.Text,
                DienThoai=txtDienThoaiHV.Text,
                NgaySinh = System.DateTime.ParseExact(Request["txtNgaysinh"], "MM/dd/yyyy", CultureInfo.InvariantCulture),
                CMND=txtCMNDHV.Text,
                Email=txtEmailHV.Text,
                GioiTinh=ddlGioiTinhHV.SelectedValue              
            };
            if (qlhocvien.ThemHocVien(hv))
            {
               
                Response.Write("<script language='javascript' type='text/javascript'>"
                           + " alert('Thêm học viên thành công');"
                           + "</script>");
                reset();
            }
            else
            {
                Response.Write("<script language='javascript' type='text/javascript'>"
                           + " alert('Không thể thêm học viên này');"
                           + "</script>");
            }
           
            
        }
        private void reset()
        {
            txtCMNDHV.Text = "";
            txtMaHV.Text= "";
            txtHoTenHV.Text= "";
            txtDiaChiHV.Text= "";
            txtDienThoaiHV.Text= "";
            txtCMNDHV.Text= "";
            txtEmailHV.Text = "";
        }

        protected void btnQuayLai_Click(object sender, EventArgs e)
        {
            Response.Redirect("QuanLyHocVien.aspx");
        }
    }
}